<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
/*
Route::get('/', function () {
    return view('welcome');
});
*/

// Route::redirect('/', 'h5');
Route::any('/', function () {
    return "hello world";
});
// Route::redirect('qyH5', 'qyH5');
Route::redirect('index', 'h5');
Route::redirect('/admin/login', 'admin');

//Route::any('dev', [\App\Http\Controllers\TestController::class, 'index'])->name('web.index');
Route::any('testSession', function () {
    session()->put('name', 'KeenSting');
    $form = '<p>hello world</p>';
    return $form;
});
Route::any('testSession2', function () {
    return session()->all();
});

Route::any('test', function () {
    $a = captcha_for_api();

    if (request()->getMethod() == 'POST') {
        $rules = ['captcha' => 'required|captcha_api:' . request('key')];
        $validator = validator()->make(request()->all(), $rules);
        if ($validator->fails()) {
            echo '<p style="color: #ff0000;">Incorrect!</p>';
        } else {
            echo '<p style="color: #00ff30;">Matched :)</p>';
        }
    }

    $form = '<form method="post" action="test">';
    $form .= '<input type="hidden" name="_token" value="' . csrf_token() . '">';
    $form .= '<p><img src="' . $a['img'] . '" alt=""></p>';
    $form .= '<p><input type="text" value="' . $a['key'] . '" name="key"></p>';
    $form .= '<p><input type="text" name="captcha"></p>';
    $form .= '<p><button type="submit" name="check">Check</button></p>';
    $form .= '</form>';
    return $form;
});


// Route::any('mini/payCallbackV2/{code}/{id}', [\App\Http\Controllers\V1\PayController::class, 'payCallbackV2'])->name('payCallbackV2');
